home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / mail / mh / contrib / queuemh / queuemh-scripts / ptize < prev    next >
Encoding:
Text File  |  1992-11-08  |  2.1 KB  |  116 lines

  1. #!/bin/sh
  2. #
  3. #  Helen Wong
  4. #  July 14,1991
  5. #
  6. #
  7. #  Modified by: juola Friday May 8
  8. #    Updated priority descriptions
  9. #
  10. #  Modified by: dyker Friday Mar 20 13:13:48 MST 1992
  11. #       cleaned-up/took-out lots of superfluous stuff
  12. #       fixed setting of folder
  13. #       fixed the ed stuff - (some machines don't deal with /)
  14. #       made it so it deals with only the first 25 lines
  15. #       consolidated mhpath commands so it's only executed once
  16. #       added recognition of last, first, next, prev, and cur as valid msgs
  17. #   
  18. #  This program inserts a Priority component and a priority in a mh message.
  19.  
  20. PATH=/usr/local/mh/bin:/bin:/usr/bin:/usr/ucb
  21. component="Priority:"
  22. form="-form /homes/troubmh/Mail/pscan.form"
  23. usage="usage: $0 [msg] [+folder] priority
  24.     msg: one msg
  25.     priority: [A-z][0-9]
  26.     Priorities:  
  27.        Type                   Effect
  28.     A. Time Critical         1. Accelerated
  29.     B. Broken no workaround        2. Multiple Users
  30.     C. Installs             3. Single faculty/staff
  31.     D. Broken with workaround    4. Single student/other"
  32.  
  33. if [ $# -eq 0 ]
  34. then
  35.     echo  "$usage"
  36.     exit 1
  37. fi
  38.  
  39. while [ $# -ne 0 ]
  40. do
  41.     case $1 in
  42.       
  43.       +*)    if [ -n "$folder"  ]
  44.         then
  45.             echo "folder: one folder"
  46.             exit 1
  47.         else
  48.             folder=$1
  49.             mhpath $folder >/dev/null 2 >&1
  50.             if [ $? -ne 0  ]
  51.             then
  52.                 echo  "$folder does not exist"
  53.                 exit 1
  54.             fi
  55.         fi;;
  56.     
  57.     [0-9]*|last|first|cur|next|prev)    
  58.         if [ -n "$msg"  ]
  59.         then
  60.             echo "$usage"
  61.             exit 1
  62.         else
  63.             msg=$1
  64.         fi;;
  65.  
  66.    [A-z][0-9])    priority=""
  67.         if [ -n  "$priority" ]
  68.         then
  69.             echo "$usage"
  70.             exit 1
  71.         else
  72.             priority=`echo $1 | tr a-z A-Z`
  73.         fi;;
  74.         -help)  echo  "$usage"
  75.         exit 0;;
  76.         
  77.         *)    echo  "$usage"
  78.         exit 1;;
  79.  
  80.     esac
  81.     shift
  82.  
  83. done
  84.  
  85. # set defaults
  86. folder="${folder-+${FOLDER-`folder -fast`}}"
  87. msg=${msg-cur}
  88.  
  89. msgpath=`mhpath $folder $msg 2>/dev/null`
  90. if [ "$msgpath" = "" ] 
  91. then 
  92.     echo  "Current message does not exist"
  93.     exit 1
  94. fi
  95.  
  96. if [ -z "$priority"  ]
  97. then 
  98.     echo    "$usage"
  99.     exit 1
  100. fi
  101.  
  102. annotate="anno $folder $msg -nodate -inplace -component $component -text $priority"
  103.  
  104. head -25 $msgpath | grep -s "^$component"
  105. if [ $? -eq 0  ]     
  106. then
  107.     ed -s $msgpath <<END
  108.     1,25s/$component.*/$component $priority/
  109.     w
  110.     q
  111. END
  112. else 
  113.     $annotate
  114. fi
  115. scan $folder $msg $form
  116.